/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

function dialogChangeOffice() {
    var selectedRow = $('#component_table tr.row_selected')[0];
    var id = selectedRow.id;
                        
    if (!$(selectedRow).hasClass('deleted')) {
    
        $.ajax({
           "url" : 'a_dialog_move_to_office',
           "data" : {"componentId" : id},
           "type" : 'GET',
           "success" : function (html) {
               $.Dialog({
                  "title": "Сменить офис...",
                  "draggable": true,
                  "content": html,
                  "width":450,
                  "onShow": function() {
                        setDatepickerDefDate('select_date_data');
                  }
               });
           }
        });
    
    }
}

function mtoOfficeChanged() {
   var select = document.getElementById('dialog_mto_select_office');
   var officeId = select.value;
   if (officeId !== '-1') {
        select.options[0].disabled = true;
        document.getElementById('move_office_id').value = officeId;
    }
}

function moveComponentToOffice(movedId) {
    var offcId = document.getElementById('move_office_id').value;
    var date = $('#select_date_data').val();
    $.ajax({
           "url":'a_dialog_move_to_office',
           "data":{"compId":movedId,"date":date,"offcId":offcId},
           "type":'POST',
           "dataType":'json',
           "success": function(json) { 
               notifyUpdateResult({
                  "errorVal":json.errorVal,
                  "successMessage":'Оборудование перемещено.',
                  "dataTableId":'component_table',
                  "datepickerId":'move_employee_date' 
               });
           }
        });
}
